package model;

import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.event.MouseEvent;
import java.awt.geom.Point2D;
import java.util.ArrayList;

import javax.swing.ImageIcon;

public class World 
{
	private Player player;
	private ArrayList<NPC> npcs;
	private int iWidth, iHeight;
	private ImageIcon imageIcon;
	
	public World(int iWidth, int iHeight)
	{
		player = new Player(iWidth / 20, iHeight / 20, 50.0, 50.0);
		
		npcs = new ArrayList<NPC>();
		imageIcon = new ImageIcon("src/images/map.png");
		
		
		RandomNPC randomNPCOne = new RandomNPC(400, 400, 20, 20);
		RandomNPC randomNPCTwo = new RandomNPC(600, 600, 30, 30);
		
		npcs.add(randomNPCTwo);
		npcs.add(randomNPCOne);
		
		this.iWidth = iWidth;
		this.iHeight = iHeight;
	}
	
	public Player getPlayer()
	{
		return player;
	}
	
	public void update()
	{
		for(NPC npc : npcs)
			npc.update();
	}
	
	public void render(Graphics2D g2d)
	{
		g2d.setColor(Color.GREEN);
		g2d.drawImage(imageIcon.getImage(), 0, 0, null);

		
		for(NPC npc : npcs)
			npc.render(g2d);
		
		player.draw(g2d);
	}

	public void mouseClick(Point2D.Double translatedPoint) 
	{
		for(NPC npc : npcs)
		{
			if(npc.getHitBox().contains(translatedPoint))
				System.out.println(npc.toString());
		}
	}
}
